__kernel void transform_vec3(
    __global const float* mat,  // Input 4x4 matrix, flattened and in column-major order
    __global const float* vec,  // Input vector
    __global float* result,      // Output
    const int numRows) {
    int i = get_global_id(0);

    if(i < numRows){
        float x = vec[i];
        float y = vec[i + numRows];
        float z = vec[i + 2 * numRows];
        result[i] = x * mat[0] + y * mat[4] + z * mat[8];
        result[i + numRows] = x * mat[1] + y * mat[5] + z * mat[9];
        result[i + 2 * numRows] = x * mat[2] + y * mat[6] + z * mat[10];
    }
}